#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305)// warning C4305:'argument' :truncation from 'double' to 'float'
#endif

//Specifing PowerStone
class SCRIPT_DECL PowerStone :public GossipScript
{
public:
void GossipHello(Object * pObject, Player* pPlayer, bool AutoSend);
void GossipSelectOption(Object * pObject, Player* pPlayer, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* pPlayer){ GossipScript::GossipEnd(pObject, pPlayer); }
void Destroy(){ delete this; }
};

void PowerStone::GossipHello(Object* pObject, Player * pPlayer, bool AutoSend)
{
if(pPlayer->CombatStatus.IsInCombat())
{
pPlayer->BroadcastMessage("You are in combat!");
return;
}
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, pPlayer);
Menu->AddItem(5, "Set my Power to to Mana", 1);
Menu->AddItem(5, "Set my Power to to Rage", 2);
Menu->AddItem(5, "Set my Power to to Energy-Rogues Only", 3);
if(AutoSend) Menu->SendTo(pPlayer);


}

void PowerStone::GossipSelectOption(Object* pObject, Player* pPlayer, uint32 Id, uint32 IntId, const char * Code)
{
	Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
	if(pCreature==NULL)
		return;

GossipMenu * Menu;
switch(IntId){

case 1: //Mana
{
	pPlayer->load_mana=1000;
	pPlayer->SetUInt32Value(UNIT_FIELD_POWER1,15000);
	pPlayer->SetUInt32Value(UNIT_FIELD_MAXPOWER1,15000);
		pPlayer->SetPowerType(POWER_TYPE_MANA);
		uint32 mc = pPlayer->GetUInt32Value(UNIT_FIELD_STAT3);
		mc = ((mc-20)*15)+20;
		pPlayer->SetUInt32Value(UNIT_FIELD_MAXPOWER1, mc);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER1, mc);
		pPlayer->load_mana=mc;
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER2, 0);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER3, 0);

}
break;

case 2: //Rage
{
		pPlayer->SetPowerType(POWER_TYPE_RAGE);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER1, 0);
		pPlayer->SetUInt32Value(UNIT_FIELD_MAXPOWER2, 1000);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER2, 0);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER3, 0);
}
break;

case 3: //Things for 1gold
{
		pPlayer->SetPowerType(3);
		pPlayer->SetUInt32Value(UNIT_FIELD_MAXPOWER3, 1000);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER3, 1000);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER1, 0);
		pPlayer->SetUInt32Value(UNIT_FIELD_POWER2, 0);
}
break;
}
}


void SetupPowerStone(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new PowerStone();
mgr->register_item_gossip_script(40044, gs);
}